﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace lcs.Web.pmtypeinfo
{
    public partial class Modify : Page
    {

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
                {
                    int pmtid = (Convert.ToInt32(Request.Params["id"]));
                    ShowInfo(pmtid);
                }
            }
        }

        private void ShowInfo(int pmtid)
        {
            lcs.BLL.pmtypeinfo bll = new lcs.BLL.pmtypeinfo();
            lcs.Model.pmtypeinfo model = bll.GetModel(pmtid);
            this.lblpmtid.Text = model.pmtid.ToString();
            this.txtpmid.Text = model.pmid.ToString();
            this.txtpmtype.Text = model.pmtype;

        }

        public void btnSave_Click(object sender, EventArgs e)
        {

            string strErr = "";
            if (!PageValidate.IsNumber(txtpmid.Text))
            {
                strErr += "采购类别表格式错误！\\n";
            }
            if (this.txtpmtype.Text.Trim().Length == 0)
            {
                strErr += "采购类别不能为空！\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int pmtid = int.Parse(this.lblpmtid.Text);
            int pmid = int.Parse(this.txtpmid.Text);
            string pmtype = this.txtpmtype.Text;


            lcs.Model.pmtypeinfo model = new lcs.Model.pmtypeinfo();
            model.pmtid = pmtid;
            model.pmid = pmid;
            model.pmtype = pmtype;

            lcs.BLL.pmtypeinfo bll = new lcs.BLL.pmtypeinfo();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功！", "List.aspx");

        }


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("List.aspx");
        }
    }
}
